<h1>Contacts</h1>

<% if not @contacts.empty? %>
  <table class='table table-striped table-hover'>
    <thead>
      <tr>
        <th>Name</th>
        <th>Email</th>
        <% if current_user %>
          <th></th>
        <% end %>
      </tr>
    </thead>

    <tbody>
      <% @contacts.each do |contact| %>
        <tr>
          <td><%= link_to contact.name, contact %></td>
          <td><%= contact.email %></td>
          <% if current_user %>
            <td style='text-align:right;'>
              <%= link_to 'Edit', edit_contact_path(contact), class: 'btn btn-default btn-xs' %>
              <%= link_to 'Destroy', contact, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-xs btn-danger' %>
            </td>
          <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <p>
    No contacts found.
  </p>
<% end %>

<% if current_user %>
  <div class='form-actions'>
    <%= link_to 'New Contact', new_contact_path, class: 'btn btn-primary' %>
  </div>
<% end %>
